// stores/counter.js
import { defineStore } from 'pinia';
import { ref, computed } from "vue";
interface Book {
  logo?: string
  name?: number
}
export const useCounterStore = defineStore('counter', {
  state: () => ({ 
    token: uni.getStorageSync('storage_key') 
    ? uni.getStorageSync('storage_key') : null,


    user:  uni.getStorageSync('user_key') 
    ? JSON.parse(uni.getStorageSync('user_key'))  : {},
task: uni.getStorageSync('task') 
? JSON.parse(uni.getStorageSync('task'))  : []
,
 
  }),
  getters: {
    double: (state) => state.token
  },
  actions: {
    increment(token: string) {
      this.token = token

      
 uni.setStorageSync('storage_key', token);
    },
    incrementask(tasks:any) {
      
    

      
 uni.setStorageSync('task', JSON.stringify(tasks));
 this.task = tasks
    },
    removeTkeen(){
      uni.removeStorageSync('storage_key');
      this.token=null
    },
    incrementName(user:Book) {
      this.user = user

      
 uni.setStorageSync('user_key', JSON.stringify(user));
    },

  },
})